import {
  BackSide,
  BoxGeometry,
  GridHelper,
  Mesh,
  MeshBasicMaterial,
  Object3D,
  PlaneGeometry,
  ShadowMaterial,
} from "three";
export const LoadModel: EditorPlugin = {
  install: (editor: Editor) => {
    const geometry = new BoxGeometry(100, 100, 100);
    const material = new MeshBasicMaterial({ color: 0x00ff00 });
    const cube = new Mesh(geometry, material);
    editor.scene.add(cube);
    const outlineMaterial = new MeshBasicMaterial({
      color: 0xff0000,
      side: BackSide,
    });
    const outlineMesh = new Mesh(geometry, outlineMaterial);
    const { x, y, z } = cube.position;
    outlineMesh.position.set(x, y, z);
    outlineMesh.scale.multiplyScalar(1.05);
    editor.scene.add(outlineMesh);
    const splineHelperObjects: Object3D[] = [];
    splineHelperObjects.push(cube);
    const planeGeometry = new PlaneGeometry(2000, 2000);
    planeGeometry.rotateX(-Math.PI / 2);
    const planeMaterial = new ShadowMaterial({ color: 0x000000, opacity: 0.2 });
    const plane = new Mesh(planeGeometry, planeMaterial);
    plane.position.y = -200;
    editor.scene.add(plane);
    const helper = new GridHelper(2000, 100);
    helper.position.y = -199;
    editor.scene.add(helper);
    editor.render();
  },
};
